package com.xulinhao.staservice.schedule;/**
 * @author xulinhao
 * @create 2021-09-19 22:30
 */

import com.xulinhao.staservice.service.StatisticsDailyService;
import com.xulinhao.staservice.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Author xlh
 * @packagename: com.xulinhao.staservice.schedule
 * @classname: ScheduledTask
 * @Description:
 * @Date 2021/9/19
 */
@Component
public class ScheduledTask {

    @Autowired
    private StatisticsDailyService dailyService;

    /**
     * 每天凌晨1点执行定时
     */
    @Scheduled(cron = "0 0 1 * * ?")
    public void task2() {
        //获取上一天的日期
        String day = DateUtil.formatDate(DateUtil.addDays(new Date(), -1));
        dailyService.registerCount(day);
    }
}
